#include<iostream>
#include<cstdio>
using namespace std;
long long int n,l,r;
long long int maxn,s;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r/n<2){
		cout<<r-n;
	}else{
		for(long long int i=r;i>=l;i--){
			s=i%n;
			if(s>maxn) maxn=s;
		}
	}
	cout<<maxn;
	return 0;
	fclose(stdin);
	fclose(stdout);
}
